package com.light.gulimall.product.web;

import com.light.gulimall.product.service.SkuInfoService;
import com.light.gulimall.product.vo.SkuDetailsVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Slf4j
@Controller
public class ItemController {

    @Autowired
    private SkuInfoService skuInfoService;

    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) {
        try {
            //根据skuId查询详情信息
            SkuDetailsVO vo = skuInfoService.skuItem(skuId);

            model.addAttribute("item", vo);

            return "item";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
